import React, { useEffect } from "react"
import { useSelector,useDispatch } from "react-redux"
import {Alert} from '@mui/material'
export default function Toast(){
  let dispatch = useDispatch();
  // isshow  true  false
  let {isshow,type,message} = useSelector((state:Istore)=>state.toastData)
  useEffect(()=>{
    if(isshow){
      setTimeout(()=>{
        dispatch({
          type:"toast_hide",
          value:false
        })
      },1500)
    }
  },[isshow])
  return(
    <div style={{display:isshow?"block":"none"}}>
      <Alert severity={type}>{message}</Alert>
    </div>
  )
    
  
}